package com.lv.service.impl;

import com.lv.mapper.AdminMapper;
import com.lv.model.Admin;
import com.lv.model.AdminExample;
import com.lv.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper am;

    @Override
    public Admin getAdminByUserName(String username) {
        AdminExample example = new AdminExample();
        AdminExample.Criteria criteria = example.createCriteria();
        criteria.andUsernameEqualTo(username);
        List<Admin> admins = am.selectByExample(example);
        return admins == null || admins.isEmpty() ? null : admins.get(0);
    }
}
